<template>
  <div id="app">
    <router-view/>
  </div>
</template>

<script>
// 引入统一封装 api
import { getAddressList, getSearchList, getShopList, getBannerList } from './api';
import { mapState } from 'vuex';
import axios from 'axios';

export default {
  name: 'App',
  async created() {
    // axios.get('/api/cityList').then(res => {
    //   console.log(res.data);
    // })
    // 请求数据
    const addressList = await getAddressList();
    // const searchList = await getSearchList({ pageSize: this.pageSize, pageNum: this.pageNum });
    const shopList = await getShopList();
    const bannerList = await getBannerList();

    // 把当前的数据存储到 vuex 中
    this.$store.dispatch('getAddressList', addressList.data);
    // if(searchList.data.code === 200) {
    //   this.$store.dispatch('getSearchList', searchList.data);
    // }
    this.$store.dispatch('getShopList', shopList.data);
    if(bannerList.data.code === 200) {
      this.$store.dispatch('getBannerList', bannerList.data.data);
    }
  },
  computed: {
    ...mapState(['pageSize', 'pageNum'])
  }
}
</script>

<style lang="scss">
* {
  padding: 0;
  margin: 0;
  text-decoration: none;
}
html, body, #app {
  width: 100%;
  height: 100%;
  /* overflow: hidden; */
}
.active {
  color: #0089dc;
}
</style>
